// http://chst.vip:1234/api/getmoneyctrl?pageid=0
//内容
let falg = true
function p(shopid = 0, areaid = 0) {
        $.ajax({
            url: "http://chst.vip:1234/api/getgsproduct",
            //
            //http://chst.vip:1234/api/getgsproduct?shopid=1&areaid=0
            data: {
                // pageid: index,
                shopid: shopid,
                areaid: areaid,
            },
            
        })
        .then(res => {
            console.log(res);
            let html = ""
            res.result.forEach(item => {
                html += ` 
                        <p>
                        <img src="${item.productImg}"></img>
                        <span>${item.productName}</span>
                        <span>${item.productPrice}</span>
                        </p>
    
                    </li>`
            });

            $("#uu")[0].innerHTML = html

        })
}
p()
function fn(url) {
    $.ajax({
        url: url,
        success(res) {
            if (res.result.length === 3) {
                let html = ""
                res.result.forEach(item => {
                    html += ` <li shopId=${item.shopId}>${item.shopName}</li>`
                })
                $('.nav')[0].innerHTML = html
                $('.nav li').click(function () {
                    let index = this.getAttribute('shopId')
                    $("#jing b")[0].innerText = this.innerText
                    jing()
                    p(index)
                })
            } else {
                let html = ""
                res.result.forEach(item => {
                    html += ` <li areaId = ${item.areaId}>${item.areaName}</li>`
                })
                $('.nav')[0].innerHTML = html
                $('.nav li').click(function () {
                    let index = this.getAttribute('areaId')
                    let text = this.innerText
                    text = text.substr(0, 2)
                    $("#hua b")[0].innerText = text
                    hua()
                    p(0, index)
                })
            }

        },
        error(err) {
            console.log(err);
        }
    })
}
//=======================================================
//下拉菜单按键
function jing() {
    $('.nav')[0].innerHTML = ''
    fn('http://chst.vip:1234/api/getgsshop')
    $("#hua span")[0].innerHTML = '▼'
    $("#aside").stop().hide()
    falg = !falg
    if (falg) {
        $("#jing span")[0].innerHTML = '▼'
        $("#aside").stop().hide()

    } else {
        $("#jing span")[0].innerHTML = '▲'
        $("#aside").stop().show()
    }
}
function hua() {
    $('.nav')[0].innerHTML = ''
    fn('http://chst.vip:1234/api/getgsshoparea')
    $("#jing span")[0].innerHTML = '▼'
    $("#aside").stop().hide()
    falg = !falg
    if (falg) {
        $("#hua span")[0].innerHTML = '▼'
        $("#aside").stop().hide()
    } else {
        $("#hua span")[0].innerHTML = '▲'
        $("#aside").stop().show()
    }
}
$("#jing").click(function () {
    jing()
})
$("#hua").click(function () {
    hua()
})
//=======================================================